# -*- coding: utf-8 -*-

from celery.schedules import crontab

broker_url = 'redis://:chench@127.0.0.1:6379/1'
result_backend = 'redis://:chench@127.0.0.1:6379/2'

# ubuntu 20.04
# broker_url = 'redis://:@172.25.27.115:6379/1'
# result_backend = 'redis://:@172.25.27.115:6379/2'

# hijack打劫：日志配置
worker_hijack_root_logger = False
# 默认不会出现STARTED状态
task_track_started = True

# worker预取任务乘数
# worker_prefetch_multiplier = 1
# 任务执行完成后确认
# task_acks_late = True

# worker崩溃后拒绝未ack的任务
# task_reject_on_worker_lost = True

# 急切：任务本地执行
# task_always_eager = True
# 急切：执行抛出异常
# task_eager_propagates = True

# task_ignore_result = True
result_extended = True

# broker_connection_retry_on_startup = True
# tzinfo = None

enable_utc = True
timezone = 'Asia/Shanghai'

imports = {
    'project.task',
    'package.tasks',
    'package.task1',
    'package.task2',
}

# task_routes = {
#     # 'package.task1.test_task1': {
#     #     'queue': 'queue1',
#     # },
#     # 'package.task1.demo_task1': {
#     #     'queue': 'queue1',
#     # },
#     # 'package.task2.test_task2': {
#     #     'queue': 'queue2',
#     # },
#     # 'package.task2.*': {
#     #     'queue': 'queue2',
#     # },
# }

task_serializer = 'json'
result_serializer = 'json'
accept_content = ['json']

# 定时任务调度：celery beat
beat_schedule = {
    "schedule_task": {
        "task": 'schedule_task_name',  # 名称
        "schedule": crontab(minute='*/1', hour='8-22'),
        "args": (1, 2)
    },

}
